<%--
 * @fileName save.jsp
 * @author  科泰集团教研团队
 * @createTime 2024/10/13 21:57
 * @lastModify 2024/10/13 21:57
 * @version 1.0.0
 --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>科泰超市管理系统</title>
    <%--  导入公共头部信息  --%>
    <%@include file="/WEB-INF/layout/head.jsp" %>
    <%--  有其他css样式可以在这里引入或编写  --%>
</head>

<body class="nav-md">
<div class="container body">
    <div class="main_container">
        <!-- 引入左边导航菜单 -->
        <jsp:include page="/WEB-INF/layout/left-nav.jsp"></jsp:include>
        <!-- 引入左边导航菜单 -->

        <!-- 引入顶部导航 -->
        <jsp:include page="/WEB-INF/layout/top-nav.jsp"></jsp:include>
        <!-- 引入顶部导航 -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3>${supplier.id == null ? '新增' : '修改'}供应商信息</h3>
                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_content">
                                <form action="${ctx}/main/supplier/save" enctype="multipart/form-data"
                                        class="form-horizontal form-label-left"  novalidate method="post">
                                    <%--   修改时隐藏域提交用户id  --%>
                                    <input value="${supplier.id}" name="id"  type="hidden" />
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supCode">
                                            供应商编号 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <c:if test="${empty supplier.id}">
                                                <input id="supCode" class="form-control col-md-7 col-xs-12"
                                                       value="${supplier.supCode}" name="supCode"
                                                       required="required" type="text">
                                            </c:if>
                                            <c:if test="${not empty supplier.id}">
                                                <input id="supCode" class="form-control col-md-7 col-xs-12"
                                                       value="${supplier.supCode}" name="supCode"
                                                       disabled="disabled" type="text">
                                            </c:if>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supName">
                                            供货商名称 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="supName" class="form-control col-md-7 col-xs-12"
                                                   value="${supplier.supName}" name="supName"
                                                   required="required" type="text">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supDesc">
                                            供货商描述
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="supDesc" class="form-control col-md-7 col-xs-12"
                                                   value="${supplier.supDesc}" name="supDesc"
                                                    type="text">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supContact">
                                            联系人 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="supContact" class="form-control col-md-7 col-xs-12"
                                                   value="${supplier.supContact}" name="supContact"
                                                   required="required" type="text">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supPhone">
                                            联系电话 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="supPhone" class="form-control col-md-7 col-xs-12"
                                                   value="${supplier.supPhone}" name="supPhone"
                                                   required="required" type="text">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supAddress">
                                            供货商地址
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="supAddress" class="form-control col-md-7 col-xs-12"
                                                   value="${supplier.supAddress}" name="supAddress"
                                                   type="text">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supFax">
                                            传真
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="supFax" class="form-control col-md-7 col-xs-12"
                                                   value="${supplier.supFax}" name="supFax" type="text">
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="bizPic">
                                            营业执照
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="bizPic" name="bizPic"  class="form-control col-md-7 col-xs-12" type="file" >
                                        </div>
                                    </div>
                                    <div class="ln_solid"></div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            <button id="send" type="submit" class="btn btn-success">提交</button>
                                            <button type="button" onclick="history.back()" class="btn btn-primary">返回</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 底部内容 -->
        <jsp:include page="/WEB-INF/layout/footer.jsp"></jsp:include>
        <!-- 底部内容 -->

        <script type="text/javascript" src="${ctx}/statics/js/common/save.js"></script>

        <script>
            $(function(){
                $("#supCode").on("input", function (){
                    // 输入过程中清除显示信息
                    clearInfo("#supCode");
                }).on("blur", function (){
                    // 失去焦点事件中，请求后端检查account是否存在
                    $.ajax({
                        type:"GET",//请求类型
                        url: ctx + "/main/supplier/supCodeExist",//请求的url
                        data:{ supCode: $(this).val() },//请求参数
                        dataType:"json",//ajax接口（请求url）返回的数据类型
                        success:function(data){//data：返回数据（json对象）
                            if(data.exist == 1){
                                //账号已存在，提示错误提示
                                showErrorInfoFor("#supCode", "该用户供应商编码已存在")
                            }else if(data.exist == 0){
                                //账号可用，提示正确提示
                                showSuccessInfoFor("#supCode", "该供应商编码可以使用")
                            }else if(data.error){
                                // 后台传了错误提示，显示
                                showErrorInfoFor("#supCode", data.error)
                            }
                        },
                        error:function(data){//当访问时候，404，500 等非200的错误状态码
                            showErrorInfoFor("#supCode", "请求异常，请联系管理员解决！")
                        }
                    });
                })
            })
        </script>

    </div>
</div>

</body>
</html>

